package competition;

import java.util.Scanner;

/**
 * @author ZhanBo
 * @date 2020/7/25
 */
public class MainE {

    public static void method(int [] array){
        int result = 0;
        int val = 0;
        int mid = array.length;
        for (int i = 0 ;i<mid ;i++){
            for (int j = i+1 ; j<array.length ;j++){
                val = Math.abs(i-j)*Math.min(array[i],array[j]);
                result = Math.max(result,val);
            }
        }
        System.out.println(result);
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()){
            int n = scanner.nextInt();
            int [] array = new int[n];
            for (int i = 0; i<n;i++){
                array[i] = scanner.nextInt();
            }
            method(array);
        }
    }
}
